import { http } from "@/utils/http";

/** 获取维修人员列表 */

export type RepairInfo = {
  workId: number;
  workName: string;
  workIdentity: number;
  workPartId: number;
  workStatus: number;
  workPhone: string;
};

export type GetRepairResult = {
  total: number;
  list: Array<RepairInfo>;
};

export const getRepair = (params?: object) => {
  return http.request<GetRepairResult>("get", "/api/manager/view/repair", {
    params
  });
};

/** 获取维修任务列表 */
export type ImgsInfo = {
  test: string;
  imsg: Array<string>;
};
export type TaskInfo = {
  id: number;
  taskCode: number;
  createTime: string;
  finishTime: string;
  deviceName: string;
  progress: number;
  adeviceAddress: string;
  repairDetailTestBringImgs: ImgsInfo;
  type: string;
  partId: number;
  updateType: string;
  repairResultDetailBringImgs: ImgsInfo;
};

export type GetTaskResult = {
  total: number;
  list: Array<RepairInfo>;
};

export const getTasks = (params?: object) => {
  return http.request<GetRepairResult>("get", "/api/manager/view/task", {
    params
  });
};

/** 添加维修人员 */

export type AddRepairInfo = {
  workId: number;
  workName: string;
  workIdentity: number;
  workPartId: number;
  workStatus: number;
  workPhone: string;
  workAppid: number;
};

export type AddRepairResult = {
  code: string;
  msg: string;
  data: null;
};

export const addRepair = (data?: AddRepairInfo) => {
  return http.request<AddRepairResult>(
    "post",
    "/api/tmxk/jhx/moudles/addWorker",
    {
      data
    }
  );
};

/** 删除维修人员 */

export type DeleteRepairResult = {
  code: string;
  msg: string;
  data: null;
};

export const deleteRepair = (data?: Array<number>) => {
  return http.request<DeleteRepairResult>(
    "post",
    "/api/tmxk/jhx/moudles/deleteWorker",
    {
      data
    }
  );
};

/** 管理员派单 */

export const giveTask = (params?: object) => {
  return http.request<null>("get", "/api/tmxk/jhx/moudles/giveTask", {
    params
  });
};
